Repository navigation
Wait before retrying a download whose cache write failed (0.3.1) - #21
Merged
Merged
Conversation
…g to a minute When a write to the partial cache file fails (a full disk), BufferedIOSink.flush keeps its failed future and CacheDownloader cancels. The Downloader loop then exits without its 5 s delay, and download()'s while (true) loop started a new HTTP attempt at once: 1389 requests in 3 s to a loopback origin in the new test. download() now counts attempts in a row that ended on an error (one onError reported after the last onPosition). A retained stream waits 5 s after such an attempt, doubling to 60 s; an attempt that ends cleanly resets the count. test/e2e/write_failure_test.dart blocks the partial file with a directory: one request in 3 s, and once the blocker is removed the attempt after the wait completes the download.
0.3.0 is on pub.dev, so its section loses the (unreleased) label.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a write to the partial cache file fails, for example on a full disk, a retained download no longer requests the source again at once. It now waits 5 s before the next attempt, doubling up to a minute while attempts keep failing.
Changes
HttpCacheStream.download()counts attempts in a row that ended on an error, meaning anonErrorreported after the lastonPosition._retryDelay(n)after such an attempt: 5, 10, 20, 40, then 60 s.catchpath keeps its 5 s delay and nowcontinues, so it doesn't wait twice.## 0.3.1Fixes entry, and the version goes to 0.3.1. 0.3.0 is already on pub.dev, so its section loses the(unreleased)label.Why
BufferedIOSink.flushkeeps its failed future, soCacheDownloadercancels. TheDownloaderloop then exits without its own 5 s delay, anddownload()'swhile (true)loop started a new HTTP attempt immediately. Every attempt reported an error.On a device whose storage is full, a stream kept requesting its source again and again for as long as it was retained. That costs mobile data, battery and a flood of reported errors.
Tests
test/e2e/write_failure_test.dartblocks the partial file with a directory where the file goes:dart analyze lib testis clean.